<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
<form action="#" method="GET">
    用户名:<input id = "un" type="text"><br>
    密码:<input id = "pw" type="password"><br>
    <input id = "submit" type="submit" value="提交">
</form>
</body>
<script type="text/javascript">
    var smt = document.getElementById("submit");
    smt.onclick = function(){
        var un = document.getElementById("un");
        var pw = document.getElementById("pw");
        console.log(un.Value=="");
        if(un.Value ==""){
            alert("用户名为空请重新输入");
            return false;
        }
        if(pw.Value ==""){
            alert("密码为空请重新输入");
            return false;
        }
    };
</script>
</html>